package org.hgvc.webapp.ets.jsf.beans.admin;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.faces.component.UIParameter;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;

import org.hgvc.webapp.ets.bo.CalendarCategory;
import org.hgvc.webapp.ets.bo.Package;
import org.hgvc.webapp.ets.bo.PackagePeakRates;
import org.hgvc.webapp.ets.bo.PackageProducts;
import org.hgvc.webapp.ets.bo.Partner;
import org.hgvc.webapp.ets.bo.PartnerProduct;
import org.hgvc.webapp.ets.bo.PointCategory;
import org.hgvc.webapp.ets.constant.AdminConstant;
import org.hgvc.webapp.ets.constant.CommonConstant;
import org.hgvc.webapp.ets.spring.service.AdminPackageService;
import org.hgvc.webapp.ets.spring.service.MembershipService;
import org.hgvc.webapp.ets.spring.service.PartnerService;
import org.jocsb.base.AbstractBean;
import org.jocsb.base.exception.BaseException;
import org.jocsb.base.util.SpringUtils;


public class AdminPackageBean extends AbstractBean{
	public static final String BEAN_NAME="adminPackageBean";
	
	private AdminPackageService adminPackageService;
	private PartnerService partnerService;
	private MembershipService membershipService;
	
	private List<Package> packageList;
	private List<PackageProducts> packageProductsList;
	private List<PackagePeakRates> packageNormalPeakRatesList;
	private List<PackagePeakRates> packageSuperPeakRatesList;
	private List<SelectItem> selectPackageType;
	private List<SelectItem> selectChargeType;
	private List<SelectItem> selectProductList;
	private List<SelectItem> selectPointCategory;
	private List<SelectItem> selectCalendarCategory;
	private List<SelectItem> selectPartners;
	
	private Package packageP;
	private PackageProducts packageProducts;
	private PackagePeakRates packagePeakRates;
	private PartnerProduct partnerProduct;
	private PointCategory wdPointCate;
	private PointCategory wePointCate;
	private CalendarCategory calendarCategory;
	private Partner selectedPartner;

	private List<SelectItem> selectSearchList;
	private String searchField;
	private String searchKeyword;
	private boolean catchError;
	
	
	public Partner getSelectedPartner() {
		return selectedPartner;
	}

	public void setSelectedPartner(Partner selectedPartner) {
		this.selectedPartner = selectedPartner;
	}

	public List<SelectItem> getSelectPartners() {
		return selectPartners;
	}
	
	public List<SelectItem> getSelectPointCategory() {
		return selectPointCategory;
	}
	public void setMembershipService(MembershipService membershipService) {
		this.membershipService = membershipService;
	}
	public String getSearchField() {
		return searchField;
	}
	public void setSearchField(String searchField) {
		this.searchField = searchField;
	}
	public String getSearchKeyword() {
		return searchKeyword;
	}
	public void setSearchKeyword(String searchKeyword) {
		this.searchKeyword = searchKeyword;
	}
	public List<SelectItem> getSelectSearchList() {
		return selectSearchList;
	}
	public void setAdminPackageService(AdminPackageService adminPackageService) {
		this.adminPackageService = adminPackageService;
	}
	public void setPartnerService(PartnerService partnerService) {
		this.partnerService = partnerService;
	}
	public Package getPackageP() {
		return packageP;
	}
	public void setPackageP(Package packageP) {
		this.packageP = packageP;
	}
	public List<Package> getPackageList() {
		return packageList;
	}
	public List<SelectItem> getSelectPackageType() {
		return selectPackageType;
	}
	public List<SelectItem> getSelectChargeType() {
		return selectChargeType;
	}
	public List<PackageProducts> getPackageProductsList() {
		return packageProductsList;
	}
	public PackageProducts getPackageProducts() {
		return packageProducts;
	}
	public void setPackageProducts(PackageProducts packageProducts) {
		this.packageProducts = packageProducts;
	}
	public PackagePeakRates getPackagePeakRates() {
		return packagePeakRates;
	}
	public void setPackagePeakRates(PackagePeakRates packagePeakRates) {
		this.packagePeakRates = packagePeakRates;
	}
	public List<SelectItem> getSelectProductList() {
		return selectProductList;
	}
	public PartnerProduct getPartnerProduct() {
		return partnerProduct;
	}
	public void setPartnerProduct(PartnerProduct partnerProduct) {
		this.partnerProduct = partnerProduct;
	}
	public String initPackageSetupAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		try{
			this.selectPackageType=new ArrayList<SelectItem>();
			String dailyPackageLabel=SpringUtils.getMessage("daily.package.label", new Object[]{});
			String specialPackageLabel=SpringUtils.getMessage("special.package.label", new Object[]{});
			SelectItem dailySelectItem=new SelectItem(AdminConstant.DAILY_PACKAGE,dailyPackageLabel);
			this.selectPackageType.add(dailySelectItem);
			SelectItem specialSelectItem=new SelectItem(AdminConstant.SPECIAL_PACKAGE,specialPackageLabel);
			this.selectPackageType.add(specialSelectItem);
			
			this.selectChargeType=new ArrayList<SelectItem>();
			String pointOnlyLabel=SpringUtils.getMessage("point.only.label", new Object[]{});
			String pointAndCashLabel=SpringUtils.getMessage("point.and.cash.label", new Object[]{});
			SelectItem pointOnlySelectItem=new SelectItem(AdminConstant.CHARGE_POINT,pointOnlyLabel);
			this.selectChargeType.add(pointOnlySelectItem);
			SelectItem pointAndCashSelectItem=new SelectItem(AdminConstant.CHARGE_POINT_N_CASH,pointAndCashLabel);
			this.selectChargeType.add(pointAndCashSelectItem);
			
			this.searchField=AdminConstant.SEARCH_CODE;
			this.selectSearchList=new ArrayList<SelectItem>();
			SelectItem codeSelectItem=new SelectItem(AdminConstant.SEARCH_CODE,AdminConstant.SEARCH_CODE);
			this.selectSearchList.add(codeSelectItem);
			SelectItem descSelectItem=new SelectItem(AdminConstant.SEARCH_DESC,AdminConstant.SEARCH_DESC);
			this.selectSearchList.add(descSelectItem);
			
			this.packageP=new Package();
			this.packageList=this.adminPackageService.getPackageList();
			
			this.selectPointCategory=new ArrayList<SelectItem>();
			List<PointCategory> pointCateList=this.membershipService.getPointCategoryList();
			for(PointCategory pointCategory : pointCateList){
				SelectItem selectItem=new SelectItem(pointCategory.getPointCatId(),pointCategory.getCode());
				this.selectPointCategory.add(selectItem);
			}
			
			this.wdPointCate=new PointCategory();
			this.wePointCate=new PointCategory();
			this.calendarCategory=new CalendarCategory();
			this.selectCalendarCategory=new ArrayList<SelectItem>();
			List<CalendarCategory> calendarCateList=this.partnerService.getCalendarCategoryList();
			for (CalendarCategory calendarCate : calendarCateList){
				SelectItem selectItem=new SelectItem(calendarCate.getCalendarCatId(),calendarCate.getCode() + " - " + calendarCate.getName());
				this.selectCalendarCategory.add(selectItem);
			}
			
			List<Partner> partnerList = this.partnerService.getAllActivePartnerList();
			this.selectPartners=new ArrayList<SelectItem>();
			for(Partner partner : partnerList){
				SelectItem selectPartner = new SelectItem(partner.getPartnerId(),partner.getCode() +" - "+partner.getCompName());
				this.selectPartners.add(selectPartner);
			}
			this.selectedPartner=new Partner();
		}catch(BaseException be){
			initErrorBean(be);
		}
		return outcome;
	}
	
	public String navAddPackageAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void navAddPackageActionEvent(ActionEvent event){
		this.catchError=false;
		this.packageP=new Package();
	}
	
	public String addPackageAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void addPackageActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			this.packageP.setCalendarCat(this.calendarCategory);
			this.packageP.setCreatedBy(getThisUser());
			this.packageP.setCreatedDate(new Date());
			this.packageP.setIsDeleted(CommonConstant.NOT_DELETED);
			this.packageP.setWdPointCate(this.wdPointCate);
			this.packageP.setWePointCate(this.wePointCate);
			this.packageP.setPartner(this.selectedPartner);
			this.packageP.setPackageType(AdminConstant.DAILY_PACKAGE);
			
			this.packageP= this.adminPackageService.savePackage(packageP);
			
			this.packageList=this.adminPackageService.getPackageList();
			
			navUpdatePackageActionEvent(this.packageP.getPackageId());
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String navUpdatePackageAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void navUpdatePackageActionEvent(ActionEvent event){
		UIParameter param = (UIParameter)event.getComponent().findComponent("packageId");
		String packageId=param.getValue().toString();
		navUpdatePackageActionEvent(packageId);
	}
	public void navUpdatePackageActionEvent(String packageId){
		this.catchError=false;
		try{
			
			for(Package packageL : this.packageList){
				if (packageL.getPackageId().equalsIgnoreCase(packageId)){
					this.packageP=packageL;
					this.packageProductsList=this.adminPackageService.getPackageProductsList(packageL);
					this.packageNormalPeakRatesList=this.adminPackageService.getPackagePeakRatesList(packageP, this.adminPackageService.getNormalPeakType() );
					this.packageSuperPeakRatesList=this.adminPackageService.getPackagePeakRatesList(packageP, this.adminPackageService.getSuperPeakType());
					this.wdPointCate=this.packageP.getWdPointCate();
					this.wePointCate=this.packageP.getWePointCate();
					if (this.packageP.getPartner()!=null)
						this.selectedPartner = this.packageP.getPartner();
					if (this.packageP.getCalendarCat()!=null)
						this.calendarCategory=this.packageP.getCalendarCat();
					break;
				}
			}
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	public String updatePackageAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void updatePackageActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			this.packageP.setCalendarCat(this.calendarCategory);
			this.packageP.setModifiedBy(getThisUser());
			this.packageP.setModifiedDate(new Date());
			this.packageP.setWdPointCate(this.wdPointCate);
			this.packageP.setWePointCate(this.wePointCate);
			this.adminPackageService.updatePackage(packageP);
			
			this.packageList=this.adminPackageService.getPackageList();
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String deletePackageAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void deletePackageActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			List<Package> deleteList=new ArrayList<Package>();
			for(Package packageL : this.packageList){
				if (packageL.isMarkAsSelect())
					deleteList.add(packageL);
			}
			this.adminPackageService.deletePackage(deleteList);
			this.packageList=this.adminPackageService.getPackageList();
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String searchPackageAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void searchPackageActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			this.packageList=this.adminPackageService.getPackageList(searchField, searchKeyword);
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String navAddPackageProductAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void navAddPackageProductActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			this.packageProducts=new PackageProducts();
			this.partnerProduct=new PartnerProduct();
			this.selectProductList=new ArrayList<SelectItem>();
			List<PartnerProduct> list=this.partnerService.getPartnerProductApprovedList(this.selectedPartner.getPartnerId());
			for(PartnerProduct partnerProduct : list){
				SelectItem selectItem = new SelectItem(partnerProduct.getPartnerProductId(),partnerProduct.getCode()+" - "+partnerProduct.getDesc());
				this.selectProductList.add(selectItem);
			}
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	public String addPackageProductAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void addPackageProductActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			this.packageProducts.setPartnerProduct(this.partnerProduct);
			this.packageProducts.setPackages(this.packageP);
			this.packageProducts.setCreatedBy(getThisUser());
			this.packageProducts.setCreatedDate(new Date());
			this.packageProducts.setIsDeleted(CommonConstant.NOT_DELETED);
			this.adminPackageService.savePackageProducts(this.packageProducts);
			this.packageProductsList=this.adminPackageService.getPackageProductsList(this.packageP);
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String navUpdatePackageProductAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void navUpdatePackageProductActionEvent(ActionEvent event){
		this.catchError=false;
		UIParameter param=(UIParameter)event.getComponent().findComponent("packageProductId");
		
		try{
			this.partnerProduct=new PartnerProduct();
			String packageProductId=param.getValue().toString();
			for(PackageProducts PackageProductsL : this.packageProductsList){
				if (PackageProductsL.getPackageProductId().equalsIgnoreCase(packageProductId)){
					this.packageProducts=PackageProductsL;
					partnerProduct=this.packageProducts.getPartnerProduct();
					break;
				}
			}
			
			this.selectProductList=new ArrayList<SelectItem>();
			List<PartnerProduct> list=this.partnerService.getPartnerProductApprovedList();
			for(PartnerProduct partnerProduct : list){
				SelectItem selectItem = new SelectItem(partnerProduct.getPartnerProductId(),partnerProduct.getCode()+" - "+partnerProduct.getDesc());
				this.selectProductList.add(selectItem);
			}	
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
		
		
		
	}
	public String updatePackageProductAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void updatePackageProductActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			this.packageProducts.setModifiedBy(getThisUser());
			this.packageProducts.setModifiedDate(new Date());
			this.adminPackageService.updatePackageProducts(packageProducts);
			this.packageProductsList=this.adminPackageService.getPackageProductsList(packageP);
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String deletePackageProductAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void deletePackageProductActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			List<PackageProducts> deleteList=new ArrayList<PackageProducts>();
			for (PackageProducts packageProductsL : this.packageProductsList){
				if (packageProductsL.isMarkAsSelect())
					deleteList.add(packageProductsL);
			}
			this.adminPackageService.deletePackageProducts(deleteList);
			this.packageProductsList=this.adminPackageService.getPackageProductsList(this.packageP);
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	//----Package Normal Peak and Super Peak------
	public String navAddPackageNormalPeakAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void navAddPackageNormalPeakActionEvent(ActionEvent event){
		this.catchError=false;
		this.packagePeakRates=new PackagePeakRates();
	}
	public String addPackageNormalPeakAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void addPackageNormalPeakActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			this.packagePeakRates.setPeakType(this.adminPackageService.getNormalPeakType());
			this.packagePeakRates.setCreatedBy(getThisUser());
			this.packagePeakRates.setCreatedDate(new Date());
			this.packagePeakRates.setIsDeleted(CommonConstant.NOT_DELETED);
			this.packagePeakRates.setPackages(this.packageP);
			this.adminPackageService.savePackagePeakRates(this.packagePeakRates);
			this.packageNormalPeakRatesList=this.adminPackageService.getPackagePeakRatesList(this.packageP,this.adminPackageService.getNormalPeakType());
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String navUpdatePackageNormalPeakAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void navUpdatePackageNormalPeakActionEvent(ActionEvent event){
		this.catchError=false;
		UIParameter param=(UIParameter)event.getComponent().findComponent("packagePeakRatesId");
		String packagePeakRatesId=param.getValue().toString();
		for(PackagePeakRates packagePeakRatesL : this.packageNormalPeakRatesList){
			if (packagePeakRatesL.getPackagePeakRatesId().equalsIgnoreCase(packagePeakRatesId)){
				this.packagePeakRates=packagePeakRatesL;
				break;
			}
		}
	}
	public String updatePackageNormalPeakAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void updatePackageNormalPeakActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			this.packagePeakRates.setModifiedBy(getThisUser());
			this.packagePeakRates.setModifiedDate(new Date());
			this.adminPackageService.updatePackagePeakRates(this.packagePeakRates);
			this.packageNormalPeakRatesList=this.adminPackageService.getPackagePeakRatesList(this.packageP,this.adminPackageService.getNormalPeakType());
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String deletePackageNormalPeakAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void deletePackageNormalPeakActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			List<PackagePeakRates> deleteList=new ArrayList<PackagePeakRates>();
			for(PackagePeakRates packagePeakRatesL : this.packageNormalPeakRatesList){
				if (packagePeakRatesL.isMarkAsSelect())
					deleteList.add(packagePeakRatesL);
			}
			this.adminPackageService.deletePackagePeakRates(deleteList);
			this.packageNormalPeakRatesList=this.adminPackageService.getPackagePeakRatesList(this.packageP,this.adminPackageService.getNormalPeakType());
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public PointCategory getWdPointCate() {
		return wdPointCate;
	}
	public void setWdPointCate(PointCategory wdPointCate) {
		this.wdPointCate = wdPointCate;
	}
	public PointCategory getWePointCate() {
		return wePointCate;
	}
	public void setWePointCate(PointCategory wePointCate) {
		this.wePointCate = wePointCate;
	}
	public List<PackagePeakRates> getPackageNormalPeakRatesList() {
		return packageNormalPeakRatesList;
	}
	public List<PackagePeakRates> getPackageSuperPeakRatesList() {
		return packageSuperPeakRatesList;
	}
	
	//-------Package Super Peak------
	public String navAddPackageSuperPeakAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void navAddPackageSuperPeakActionEvent(ActionEvent event){
		this.catchError=false;
		this.packagePeakRates=new PackagePeakRates();
	}
	public String addPackageSuperPeakAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void addPackageSuperPeakActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			this.packagePeakRates.setPeakType(this.adminPackageService.getSuperPeakType());
			this.packagePeakRates.setCreatedBy(getThisUser());
			this.packagePeakRates.setCreatedDate(new Date());
			this.packagePeakRates.setIsDeleted(CommonConstant.NOT_DELETED);
			this.packagePeakRates.setPackages(this.packageP);
			this.adminPackageService.savePackagePeakRates(this.packagePeakRates);
			this.packageSuperPeakRatesList=this.adminPackageService.getPackagePeakRatesList(this.packageP,this.adminPackageService.getSuperPeakType());
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String navUpdatePackageSuperPeakAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void navUpdatePackageSuperPeakActionEvent(ActionEvent event){
		this.catchError=false;
		UIParameter param=(UIParameter)event.getComponent().findComponent("packagePeakRatesId");
		String packagePeakRatesId=param.getValue().toString();
		for(PackagePeakRates packagePeakRatesL : this.packageSuperPeakRatesList){
			if (packagePeakRatesL.getPackagePeakRatesId().equalsIgnoreCase(packagePeakRatesId)){
				this.packagePeakRates=packagePeakRatesL;
				break;
			}
		}
	}
	public String updatePackageSuperPeakAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void updatePackageSuperPeakActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			this.packagePeakRates.setModifiedBy(getThisUser());
			this.packagePeakRates.setModifiedDate(new Date());
			this.adminPackageService.updatePackagePeakRates(this.packagePeakRates);
			this.packageSuperPeakRatesList=this.adminPackageService.getPackagePeakRatesList(this.packageP,this.adminPackageService.getSuperPeakType());
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	
	public String deletePackageSuperPeakAction(){
		String outcome=AdminConstant.NAV_STATUS_SUCCESS.concat("_"+getRoleName());
		if (this.catchError)
			outcome=null;
		return outcome;
	}
	public void deletePackageSuperPeakActionEvent(ActionEvent event){
		this.catchError=false;
		try{
			List<PackagePeakRates> deleteList=new ArrayList<PackagePeakRates>();
			for(PackagePeakRates packagePeakRatesL : this.packageSuperPeakRatesList){
				if (packagePeakRatesL.isMarkAsSelect())
					deleteList.add(packagePeakRatesL);
			}
			this.adminPackageService.deletePackagePeakRates(deleteList);
			this.packageSuperPeakRatesList=this.adminPackageService.getPackagePeakRatesList(this.packageP,this.adminPackageService.getSuperPeakType());
		}catch(BaseException be){
			this.catchError=true;
			initErrorBean(be);
		}
	}
	public List<SelectItem> getSelectCalendarCategory() {
		return selectCalendarCategory;
	}
	public CalendarCategory getCalendarCategory() {
		return calendarCategory;
	}
	public void setCalendarCategory(CalendarCategory calendarCategory) {
		this.calendarCategory = calendarCategory;
	}
}
